from base.base_action import BaseAction
from page import constants


class SmsPage(BaseAction):

    def __init__(self, driver):
        super().__init__(driver)

    def open_sms(self):
        """
        打开短信界面
        :return:
        """
        self.driver.find_element(constants.open_message)

    def click_add(self):
        """
        新建一条短信
        :return:
        """
        self.driver.find_element(constants.add_message).click()

    def click_receiver(self):
        """
        找到联系人栏，输入手机号
        :return:
        """
        self.driver.find_element(constants.receiver_box).clear().send_keys(constants.receiver_num)

    def send_sms(self):
        """
        发送短信
        :return:
        """
        self.driver.keyevent(66)
        input_wind = self.driver.find_element(constants.edit_message)
        send_icon = self.driver.find_element(constants.send_message_btn)
        send_list = constants.message_data
        for i in send_list:
            input_wind.clear()
            input_wind.send_keys(i)
            send_icon.click()
